﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Data;

namespace Exemplos.Web
{
    public partial class ExemploGridCompleta : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnPesquisar_Click(object sender, EventArgs e)
        {
            using (DBUCNEntities bd = new DBUCNEntities())
            {
                int idArea = Convert.ToInt32(this.ddlArea.SelectedValue);
                string nome = this.txtNome.Text;
                List<TBExemplo> exemplos = bd.TBExemploes.Where(q => q.Nome.Contains(nome) &&
                                                                     (idArea == 0 || q.IDArea == idArea)).ToList();

                grvExemplo.DataSource = exemplos;
                grvExemplo.DataBind();
            }
        }

        protected void grvExemplo_RowEditing(object sender, GridViewEditEventArgs e)
        {
            Response.Redirect("ExemploCadastro.aspx?id=" + grvExemplo.Rows[e.NewEditIndex].Cells[1].Text);
        }
    }
}